/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author Tiago
 */
public class DaoLocadora {
   private PreparedStatement preparededstmt;
    private Statement stmt;
    private ResultSet resultSet;
    private ConnectionFactory conexao;
    private Connection con;
    private String sql;
    public ArrayList  locadora = new ArrayList();
    


    public DaoLocadora() {
        
        this.stmt = null;
        this.resultSet = null;
        this.conexao = ConnectionFactory.getInstance();
        this.con = conexao.getConexao();
        
        



    }
    
    public ResultSet preencheLocadora() throws SQLException{
        this.sql = "SELECT * FROM tabLocadora";
         
        
             
      stmt = ConnectionFactory.getConexao().createStatement();  
      this.resultSet = stmt.executeQuery( this.sql);  
      return this.resultSet;
    
    }
    
     public ResultSet retornaParametrosLancamento() throws SQLException{
        this.sql = "SELECT * FROM tabPrecoTipo WHERE intIdPreco = 1";
         
        
             
      stmt = ConnectionFactory.getConexao().createStatement();  
      this.resultSet = stmt.executeQuery( this.sql);  
      return this.resultSet;
    
    }
    public ResultSet retornaParametrosCatalogos() throws SQLException{
        this.sql = "SELECT * FROM tabPrecoTipo WHERE intIdPreco = 2";
         
        
             
      stmt = ConnectionFactory.getConexao().createStatement();  
      this.resultSet = stmt.executeQuery( this.sql);  
      return this.resultSet;
    
    }
     public ResultSet retornaParametrosOutros() throws SQLException{
        this.sql = "SELECT * FROM tabPrecoTipo WHERE intIdPreco = 3";
         
        
             
      stmt = ConnectionFactory.getConexao().createStatement();  
      this.resultSet = stmt.executeQuery( this.sql);  
      return this.resultSet;
    
    } 
     
     
     
    public void salvaLocadora(String txtNomeLocadora, String txtCnpjLocadora, String txtTelefoneLocadora, String txtMsgCupom, String txtEnderecoLocadora, String txtEnderecoNumLocadora ) throws SQLException{
      this.sql = "UPDATE [VIDEOLOCADORA].[dbo].[tabLocadora]\n" +
        "   SET [txtNomeLocadora] = "+txtNomeLocadora+"'\n" +
        "      ,[txtCnpjLocadora] = '"+txtCnpjLocadora+"'\n" +
        "      ,[txtTelefoneLocadora] = '"+txtTelefoneLocadora+"'\n" +
        "      ,[txtMsgCupom] = '"+txtMsgCupom+"'\n" +
        "      ,[txtEnderecoLocadora] = '"+txtEnderecoLocadora+"'\n" +
        "      ,[txtEnderecoNumLocadora] = '"+txtEnderecoNumLocadora+"'\n" +
        " WHERE intIdLocadora = 1'\n" +
        "GO";
      
      this.preparededstmt = ConnectionFactory.conexao.prepareStatement(this.sql);
      if(this.preparededstmt.executeUpdate()==1){
          System.out.println("Salvo com sucesso");
      }

    }
    
}
